package Exception;

import java.io.IOException;

/**
 * @Author: Miyako
 * @Date: 2024-07-18-11:23
 * @Description: 检查与非检查异常
 */
public class CheckNonCheckException01 {

    public static void main(String[] args) {
        try{doMethod01();//接收到方法的异常，继续捕获
        }catch (IOException e){
            e.printStackTrace();
            throw new RuntimeException("程序出错了");//抛出运行时异常，程序终止
        }
        doMethod02();

    }
    public static void doMethod01 () throws IOException//检查异常，编译不通过
    {
        throw new IOException("读写异常");
    }
    public static void doMethod02()
    {
        throw new ArrayIndexOutOfBoundsException("数组越界异常");//非检查异常，编译通过
    }
}
